<?php
include "include/config.inc.php";
$documentId = array();
$documentName = array();
$m=0;
$partyId     = $_REQUEST['partyId'];
$partyName   = "";
$address     = "";
$city        = "";
$phone1      = "";
$phone2      = "";
$documentsId = "";
$otherInfo   = "";

$selectParty = "SELECT partyId, partyName, address, city, phone1, phone2, documentsId, otherInfo
                  FROM party
                 WHERE partyId = ".$partyId;
$selectPartyRes = mysql_query($selectParty);
while($selectPartyRow = mysql_fetch_array($selectPartyRes))
{
  $partyId     =  $selectPartyRow['partyId'];
  $partyName   =  $selectPartyRow['partyName'];
  $address     =  $selectPartyRow['address'];
  $city        =  $selectPartyRow['city'];
  $phone1      =  $selectPartyRow['phone1'];
  $phone2      =  $selectPartyRow['phone2'];
  $documentsId =  explode(',',$selectPartyRow['documentsId']);
  $otherInfo   =  $selectPartyRow['otherInfo'];
}
$selectDocument = "SELECT documentsId, document
                     FROM documents";
$selectDocumentRes = mysql_query($selectDocument);
while ($selectDocumentRow = mysql_fetch_array($selectDocumentRes))
{
  $documentId[$m]   = $selectDocumentRow['documentsId'];
  $documentName[$m] = $selectDocumentRow['document'];
  $selectedDocumentId[$m]   = explode(',',$selectDocumentRow['documentsId']);
  $m++;
}
$smarty->assign("documentId",$documentId);
$smarty->assign("documentName",$documentName);
$smarty->assign("partyId",$partyId);
$smarty->assign("partyName",$partyName);
$smarty->assign("address",$address);
$smarty->assign("city",$city);
$smarty->assign("phone1",$phone1);
$smarty->assign("phone2",$phone2);
$smarty->assign("documentsId",$documentsId);
$smarty->assign("otherInfo",$otherInfo);
$smarty->display('enterNewPartyAjax.tpl');
?>
